1.安装GIT
- 下载:https://desktop.github.com
- 直接安装
- 验证成功:
1
git --version

配置
1
2git config --global user.name "your name"
git config --global user.email "your_email@example.com"SSH Key
1
ssh-keygen -t rsa -C "your_email@example.com"

2.github配置
- 添加SSH Key
把上一步生成的公钥拷贝,添加到github的keys。
在GitHub上面添加本地SSH密钥信息,在右上角选择Settings进入设置界面:github - git本地
1
2
3
4
5eval `ssh-agent -s`
ssh-add hexo_rsa //上面创建的密钥文件名
```
3. **关联github验证**
登陆一下GitHub,看是否登陆成功
ssh -T git@github.com1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#### 3.创建并验证github pages
1. **创建项目**
仓库名必须遵守相应格式:your_username.github.io,这样子在访问主页的时候直接用your_username.github.io就能访问。

2. **git clone项目到本地**
3. **项目中添加一个文件:index.html**
``` vbscript-html
<!DOCTYPE html>
<html>
<body>
<h1>Hello World</h1>
<p>I'm hosted with GitHub Pages.</p>
</body>
</html>
```
4. **上传**


5. **找到URL**
github上,setting中


5. **验证**
复制该URL到浏览器

#### 4.hexo配置git
1. **将hexo的文件夹拷贝到上边的本地项目中**
2. **修改hexo/_config.yml**
deploy:
type: git
repo:
github: https://github.com/lishanying/lishanying.github.io.git
branch: master1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25注意:中间有空格
3. **绑定git**
```
cnpm install hexo-deployer-git --save
```

注意:如果此处不绑定,后续操作会出现如下异常:

#### 4.部署到github
1. **部署**
一般我们上传到GitHub的时候我们用下边命令来执行,生成静态文件并且部署到服务器。
```
hexo clean
hexo g
hexo d
```
中途会提示输入github的账号和密码。
2. **验证**

#### 5.部署到OSChina
1. **上传sshkey**
2. **验证关联**
3. **配置站点脚本**
deploy:
type: git
repo:
github: https://github.com/lishanying/lishanying.github.io.git
oschina: https://gitee.com/freeCunChangDaRen/freeCunChangDaRen.git
branch: master
4. **部署**
hexo clean
hexo g
hexo d
```
中途会提示输入github和OSChina的账号和密码。
- 验证验证OSChina托管